package com.lgl.controller;

import com.lgl.dto.ArticleDto;
import com.lgl.entity.ResponseResult;
import com.lgl.service.ArticleService;
import com.lgl.service.ArticleTagService;
import com.lgl.vo.AdminArticleDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content/article")
public class ArticleController {
    @Autowired
    private ArticleTagService articleTagService;
    @Autowired
    private ArticleService articleService;

    @PostMapping
    public ResponseResult addArticle(@RequestBody ArticleDto articleDto) {
        return articleService.addArticle(articleDto);
    }
    @GetMapping("/list")
    public ResponseResult getList(Integer pageSize,Integer pageNum,String title,String summary){
        return articleService.getList(pageSize,pageNum,title,summary);
    }
    @GetMapping("/{id}")
    public ResponseResult getAdminArticleDetil(@PathVariable Long id){
        return articleService.getAdminArticleDetil(id);
    }
    @PutMapping
    public ResponseResult updateArticle (@RequestBody AdminArticleDetailVo adminArticleDetailVo){
        return articleService.updateArticle(adminArticleDetailVo);

    }
    @DeleteMapping("/{id}")
    public ResponseResult deleteArticle(@PathVariable Long id){
        return articleService.deleteArticle(id);
    }
}
